*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*
* Diehl/Wolter: “ATTITUDES ABOUT CONTAINMENT MEASURES DURING
*                THE 2020/2021 CORONAVIRUS PANDEMIC: 
*                SELF-INTEREST, OR BROADER POLITICAL ORIENTATIONS?"
*
* Do-File for robustness checks of descriptive data analysis
*
* This version: 20210602
*
* Author: Felix Wolter, felix.wolter@uni-konstanz.de
*
*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Figure 2: Opposition against containment measures
reg openkitas5 i.time##i.east [iweight=persweight] 
est sto opkitas
suest opkitas , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store opkitas

reg openschools5 i.time##i.east [iweight=persweight] 
est sto opschools
suest opschools , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store opschools

reg openrestau5 i.time##i.east [iweight=persweight] 
est sto oprestau
suest oprestau , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store oprestau

reg opencontact5 i.time##i.east [iweight=persweight] 
est sto opcontact
suest opcontact , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store opcontact

reg openborders5 i.time##i.east [iweight=persweight] 
est sto opborders
suest opborders , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store opborders

reg openevents5 i.time##i.east [iweight=persweight] 
est sto opevents
suest opevents , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store opevents

coefplot (opkitas, msymb(O) mcolor(green*1.1) ciopts(lcolor(green*1.1))) ///
   (opschools, msymb(X) mcolor(gs12) ciopts(lcolor(gs12))) ///
   (oprestau, msymb(T) mcolor(blue) ciopts(lcolor(blue))) ///
   (opcontact, msymb(S) mcolor(red*1.5) ciopts(lcolor(red*1.5)) ) ///
   (opborders, msymb(D) mcolor(yellow*1.8) ciopts(lcolor(yellow*1.8)) ) ///
   opevents, msymb(+) mcolor(black) ciopts(lcolor(black))  /// 
   coeflabels(1._at = "May 2020, West" ///
              2._at = "May 2020, East" ///
			  3._at = "November 2020, West" ///
			  4._at = "November 2020, East", labsize(3)) ///
   graphregion(fcolor(gs15)) ///
   xlabel(1(1)4, labsize(2.5)) ///
   xline(1(.5)4, lcolor(gs12) lwidth(vthin)) ///
   legend(order(2 "Daycare" 4 "Schools" 6 "Restaurants/bars" ///
                8 "Contacts" 10 "Borders" 12 "Events") rows(2))



*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Figure 3: Individual threats by region and time
reg idtecon i.time##i.east [iweight=persweight] 
est sto idtecon
suest idtecon , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store idtecon

reg idtfamily i.time##i.east [iweight=persweight] 
est sto idtfamily
suest idtfamily , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) post
estimates store idtfamily

logit childrenathome i.time##i.east [iweight=persweight] 
est sto childrenathome
suest childrenathome , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) expression(1/(1+(exp(-(predict(xb)))))) post
estimates store childrenathome

logit incloss i.time##i.east [iweight=persweight] 
est sto incloss
suest incloss , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) expression(1/(1+(exp(-(predict(xb)))))) post
estimates store incloss

logit riskgroup01 i.time##i.east [iweight=persweight] 
est sto riskgroup01
suest riskgroup01 , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) expression(1/(1+(exp(-(predict(xb)))))) post
estimates store riskgroup01

logit old i.time##i.east [iweight=persweight] 
est sto old
suest old , vce(cluster id)
margins, at(time=(0 1) east=(0 1)) expression(1/(1+(exp(-(predict(xb)))))) post
estimates store old


*Version 1 horizontally
coefplot (idtecon, msymb(O) mcolor(red*1.5) ciopts(lcolor(red*1.5)))  ///
   idtfamily, msymb(X) mcolor(blue) ciopts(lcolor(blue))  ///
   coeflabels(1._at = "May 2020, West" ///
              2._at = "May 2020, East" ///
			  3._at = "November 2020, West" ///
			  4._at = "November 2020, East", labsize(3.5)) ///
   title("Continuous variables", size(4.5) color(black)) ///
   graphregion(fcolor(gs15)) ///
   xlabel(2(.5)3, labsize(2.5)) ///
   xline(2(.2)3, lcolor(gs12) lwidth(vthin))  ///
   legend(order(2 "Indiv. threat economic" 4 "Indiv. threat family") rows(2)) ///
   saving(figure2a.gph, replace)


coefplot (childrenathome, msymb(T) mcolor(green*1.1) ciopts(lcolor(green*1.1))) ///
   (incloss, msymb(S) mcolor(black) ciopts(lcolor(black))) ///
   (riskgroup01, msymb(+) mcolor(yellow*1.8) ciopts(lcolor(yellow*1.8)))  ///
   old, msymb(D) mcolor(gs12) ciopts(lcolor(gs12))  ///
   coeflabels(, nolabels) ///
   title("Binary variables", size(4.5) color(black)) ///
   graphregion(fcolor(gs15)) ///
   xlabel(0(.1).5, labsize(2.5)) ///
   xline(0(.1).5, lcolor(gs12) lwidth(vthin))  ///
   legend(order(2 "Children at home" 4 "Income loss" 6 "Covid-19 at-risk group" ///
                8 "Age >70") rows(2)) ///
   saving(figure2b.gph, replace)
   
graph combine "figure2a" "figure2b"



*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Table 2

bysort time east: sum sttecon [aweight=persweight]
bysort time: sum sttecon [aweight=persweight]

bysort time east: sum sttfamily [aweight=persweight]
bysort time: sum sttfamily [aweight=persweight]

bysort time east: sum doubtstate [aweight=persweight]
bysort time: sum doubtstate [aweight=persweight]

bysort time east: sum protransfer [aweight=persweight]
bysort time: sum protransfer [aweight=persweight]

bysort time east: tab leftrightcat [iweight=persweight]
bysort time: tab leftrightcat [iweight=persweight]

bysort time: tab east [iweight=persweight]

bysort time east: sum gentrust [aweight=persweight]
bysort time: sum gentrust [aweight=persweight]

bysort time east: tab female [iweight=persweight]
bysort time: tab female [iweight=persweight]

bysort time east: sum educyr [aweight=persweight]
bysort time: sum educyr [aweight=persweight]

bysort time east: sum kr_inz_rate10 [aweight=persweight]
bysort time: sum kr_inz_rate10 [aweight=persweight]

bysort time east: sum kr_tod_rate10 [aweight=persweight]
bysort time: sum kr_tod_rate10 [aweight=persweight]




